package cn.charlotte.pit.data;

import cn.charlotte.pit.ThePit;
import cn.charlotte.pit.data.sub.PlayerEnderChest;
import cn.charlotte.pit.data.sub.PlayerInv;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.ReplaceOptions;
import lombok.SneakyThrows;

import java.util.List;

/**
 * @Author: EmptyIrony
 * @Date: 2021/3/17 21:51
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class PlayerInvBackup {
    private String uuid;
    private long timeStamp;
    private String backupUuid;

    private PlayerInv inv;
    private PlayerEnderChest[] chest;

    public PlayerInvBackup() {
    }

    @SneakyThrows
    public void save() {
        ThePit.getInstance()
                .getMongoDB()
                .getInvCollection()
                .replaceOne(Filters.eq("backupUuid", backupUuid), this, new ReplaceOptions().upsert(true));
    }

    public String getUuid() {
        return this.uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public long getTimeStamp() {
        return this.timeStamp;
    }

    public void setTimeStamp(long timeStamp) {
        this.timeStamp = timeStamp;
    }

    public String getBackupUuid() {
        return this.backupUuid;
    }

    public void setBackupUuid(String backupUuid) {
        this.backupUuid = backupUuid;
    }

    public PlayerInv getInv() {
        return this.inv;
    }

    public void setInv(PlayerInv inv) {
        this.inv = inv;
    }

    public PlayerEnderChest[] getChest() {
        return this.chest;
    }

    public void setChests(PlayerEnderChest[] chest) {
        this.chest = chest;
    }
}
